﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace idataplatform
{
    public partial class fhyhysel : Form
    {
        public fhyhysel()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //pubcls.fhydselSQL = "select a.hyno,a.phoneno,a.ctime,a.jf from (select hyno,phoneno,ctime,jf from hydetail_ipark where ctime <= '" + dateTimePicker1.Value.AddDays(-730).ToShortDateString() + "') a left join (SELECT HYNO, PHONENO, JFTIME FROM(select HYNO, PHONENO, JFTIME,ROW_NUMBER() OVER(PARTITION BY hyno ORDER BY jftime DESC) Num from jfchange_ipark where jfmark <> '新用户奖励积分' AND jfmark <> '测试' AND HYNO <> '') t WHERE t.Num >= 1) b on a.hyno = b.HYNO where b.hyno is null order by a.hyno asc;";
            pubcls.fhydselSQL = "select hyno,phoneno,ctime,jf from hydetail_ipark where ctime<='" + dateTimePicker1.Value.AddDays(-730).ToShortDateString() + "' and hyno not in (SELECT t2.HYNO FROM(SELECT t1.HYNO, t1.PHONENO, ROW_NUMBER() OVER(PARTITION BY t1.HYNO) Num FROM(SELECT HYNO, PHONENO FROM jfchange_ipark where jfmark <> '新用户奖励积分' AND jfmark <> '测试' AND HYNO <> '' UNION ALL SELECT HYNO, PHONENO FROM qhxtab_ipark where HYNO <> '') t1) t2 WHERE t2.Num = 1)";
            //MessageBox.Show(dateTimePicker1.Value.AddDays(-730).ToShortDateString());
            this.DialogResult = DialogResult.OK;
            this.Dispose();
            this.Close();
        }

        private void fhyhysel_Load(object sender, EventArgs e)
        {
            dateTimePicker1.Text = System.DateTime.Now.AddDays(-1).ToShortDateString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            dateTimePicker1.Text = System.DateTime.Now.AddDays(-1).ToShortDateString();
        }
    }
}
